
# lsh.fig-- runs sh.fig with a previous shell command 
# Copyright (C) 2021 mn
#
# This program is free software: you can redistribute it and/or modify 
#
# it under the terms of the GNU Affero General Public License as published by 
# the Free Software Foundation, either version 3 of the License, or 
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License 
# along with this program. If not, see <http://www.gnu.org/licenses/>.

function vget g k
python
    return g[k]
    fig
    fig

function vset g k v
python
    g[k] = v
    return g
    fig
    fig

function lsh buf params
python
    from sh import sh
    fig
    glen    vget params "g" len
    tlen    ".lsh"    len    times -1  plus glen
    now vget params "g"        ltrim  rtrim     right tlen  ltrim val
    cmdline arrget buf now
    pb vset params "g" cmdline
    params pb
python
    pb = sh(buf, params)
    fig
    params pb return params
    fig

